package inet.app.controller.parser;


import inet.app.controller.connect.JsonParser;
import inet.app.model.object.Doso_Item;

import java.util.ArrayList;

import org.json.JSONObject;

import android.util.Log;

public class Parser_Doso {

	private Doso_Item item;
	private String ITEMS = "items";
	private String CODE = "code";
	private String NAME = "name";
	private String COUPLE = "couple";
	private String COUNTXH = "countxh";
	private String DATE = "date";
	private String NHIP = "nhip";
	private String XHDAU30= "xhdau30";
	private String LASTDATEDAU30 = "lastdatedau30";
	private String XHDUOI30 = "xhduoi30";
	private String LASTDATEDUOI30 = "lastdateduoi30";
	private String XHTONG30 = "xhtong30";
	private String LASTDATETONG30 = "lastdatetong30";
	private String DAUCHUARA = "dauchuara";
	private String DAUNGAYGANNHAT = "daungaygannhat";
	private String DUOICHUARA= "duoichuara";
	private String DUOINGAYGANNHAT = "duoingaygannhat";
	private String TONGCHUARA = "tongchuara";
	private String TONGNGAYGANNHAT = "tongngaygannhat";
	
	public Parser_Doso () {
		
	}
	public Doso_Item getList(String url) {
		JSONObject jobject,object,job_items;
		try {
				jobject = new JSONObject(url);
				
				String items = jobject.getString(ITEMS);
				job_items = new JSONObject(items);
				String code= job_items.getString(CODE);
				String name= job_items.getString(NAME);
				String couple= job_items.getString(COUPLE);
				String countxh= job_items.getString(COUNTXH);
				String date= job_items.getString(DATE);
				String nhip= job_items.getString(NHIP);
				
				String xhdau30= job_items.getString(XHDAU30);
				String lastdatedau30= job_items.getString(LASTDATEDAU30);
				String xhduoi30= job_items.getString(XHDUOI30);
				String lastdateduoi30= job_items.getString(LASTDATEDUOI30);
				String xhtong30= job_items.getString(XHTONG30);
				String lastdatetong30= job_items.getString(LASTDATETONG30);

				String dauchuara= job_items.getString(DAUCHUARA);
				String daungaygannhat= job_items.getString(DAUNGAYGANNHAT);
				String duoichuara= job_items.getString(DUOICHUARA);
				String duoingaygannhat= job_items.getString(DUOINGAYGANNHAT);
				String tongchuara= job_items.getString(TONGCHUARA);
				String tongngaygannhat= job_items.getString(TONGNGAYGANNHAT);
				
				
				item = new Doso_Item(code, name, couple, countxh, date, nhip, xhdau30, lastdatedau30, xhduoi30, lastdateduoi30, xhtong30, lastdatetong30, dauchuara, daungaygannhat, duoichuara, duoingaygannhat, tongchuara, tongngaygannhat);
				
			return item;
        } catch (Exception e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
            return null;
        }
		
	}


}
